clear

use "C:\Users\lenovo\Desktop\WongLiangPOBE\WongLiangStudy1\WongLiangStudy1.dta" 

//treatment group order and choice option
egen time = rowtotal (time1 time2 time3 time4 time5)
replace time = . if time == 0

egen timechoice = rowtotal (time1choice time2choice time3choice time4choice time5choice)
replace timechoice = . if timechoice == 0

//for all order and choice option
egen all_time = rowtotal ( all_time1 all_time2 all_time3 all_time4 all_time5 )
egen all_timeagree = rowtotal ( all_time1agree all_time2agree all_time3agree all_time4agree all_time5agree )

//generate interaction term of treatment and all_time
gen treatmentXalltime= treatment * all_time

//gen province factor variable
xi i.province

//generate dummy variables for choice of recommended comments, netizens' comments, and skip comments. 
gen recommendeddummy = 0
replace recommendeddummy = . if treatment == 0
replace recommendeddummy = 1 if timechoice == 1

gen netizendummy = 0
replace netizendummy = . if treatment == 0
replace netizendummy = 1 if timechoice == 2

gen skipdummy = 0
replace skipdummy = . if treatment == 0
replace skipdummy = 1 if timechoice == 3


// ------- Comment Viewing Trend ----------------

//for treatment group analysis only - set dataset as time series and run multinomial logistic model
tsset id time
sort id time
mlogit timechoice time ini_recommended ini_netizen male age ccp edu _I* income poli_interest news_consumption frequent_use most_recent_use discussion, base(2) vce(cluster id)
estimate store m1

//for treatment group analysis only - declare dataset to be panel data and run random-effects logistic model
xtset id time
xtlogit recommendeddummy time ini_recommended ini_netizen male age ccp edu _I* income poli_interest news_consumption frequent_use most_recent_use discussion , vce(cluster id)
estimate store m2

//generate Table 2 specification 5 and 6
estout *, cells (b(star fmt(%8.3f)) se(par fmt(%8.3f))) stats(N11, fmt(%8.5g)) drop(_I*) starlevels(* 0.05 ** 0.01) style(fixed)
estimate drop *

